/*
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package hextd.server;

import com.twolattes.json.Entity;
import com.twolattes.json.Value;
import java.util.HashSet;
import java.util.Set;

@Entity
public class PlayerInfo {

	@Value(optional = true)
	public int userId;
	@Value(optional = true)
	public int rank;
	@Value(optional = true)
	public int games;
	@Value(optional = true)
	public String userName = "PlayerX";
	@Value(optional = true)
	public String userRights;
	@Value(optional = true)
	public String token;
	@Value(optional = true)
	public Set<Integer> maps = new HashSet<Integer>();

	public PlayerInfo() {
	}

	public void updateFrom(PlayerInfo info, boolean trustedSource) {
		if (trustedSource) {
			userId = info.userId;
			rank = info.rank;
			games = info.games;
			userName = info.userName;
			userRights = info.userRights;
		}
		token = info.token;
		maps.addAll(info.maps);
	}
}
